﻿package com.thorqq.magictimer.core;

import com.thorqq.magictimer.util.Util;

import android.view.View;
import android.widget.ScrollView;

public abstract class ChildView
{
    //获取布局
    public View getLayoutView()
    {
        return mView;
    }
    //初始化
    public void initLayout(ChildViewParent parent)
    {
            Util.log("ChildView.initLayout");
            this.doInitLayout(parent);
            this.mInit = true;
            this.updateLayout();
            this.registerListener();
    }
    //判断是否已经初始化
    public boolean isInitialize()
    {
        return mInit;
    }
    //更新布局
    public abstract void updateLayout();
    
    public abstract void onClose();
    
    //parentScrollView：上层ScrollView。如果下层存在需要滚动的控件，需要调用这个方法
    public void setParentScrollView(ScrollView parentScrollView)
    {
        doSetParentScrollView(parentScrollView);
    }
    
    public void setTag(Object object)
    {
        mTag = object;
        doSetTag(object);
    }

    public Object getTag()
    {
        return mTag;
    }
    //
    protected abstract void registerListener();
    protected abstract void doInitLayout(ChildViewParent parent);
    protected abstract void doSetTag(Object object);
    protected void doSetParentScrollView(ScrollView parentScrollView) {}
    
    protected View mView;
    protected ScrollView mParentScrollView;
    protected Object mTag;
    protected boolean mInit = false;
}
